package com.formula.datastructure.exercise.graph.undirect;

public class ListVertex {
    public String data;
    public ListEdge firstEdge;

    public ListVertex() {

    }

    public ListVertex(String data) {
        this.data = data;
    }

    public ListVertex(String data, ListEdge firstEdge) {
        this.data = data;
        this.firstEdge = firstEdge;
    }

    public void addEdge(ListEdge edge) {
        if (firstEdge == null) {
            firstEdge = edge;
        } else {
            ListEdge tempEdge = firstEdge;
            while (tempEdge.nextEdge != null) {
                tempEdge = tempEdge.nextEdge;
            }
            tempEdge.nextEdge = edge;
        }
    }
}
